package com.grep.extra.servlet;

import java.util.Iterator;
import java.util.List;

import com.grep.extra.dao.impl.TaskDAOSQL;
import com.grep.extra.dao.impl.WebSiteDAOSQL;
import com.grep.extra.factory.data.impl.SiteUrl;
import com.grep.extra.factory.data.impl.TaskContentUrl;
import com.grep.extra.factory.data.impl.TaskDataQueue;
import com.grep.extra.factory.data.impl.TaskUrl;
import com.grep.extra.factory.handle.IHandler;
import com.grep.extra.factory.handle.impl.ContentUrlHandler;
import com.grep.extra.factory.handle.impl.TaskUrlHandler;
import com.grep.extra.service.CollectTask;
import com.grep.extra.service.impl.CollectTaskImpl;
/**
 * 
 * @author yuyang
 */
public class CollectContUrl {

	public CollectContUrl(String taskid,String siteid) {
		
		WebSiteDAOSQL webSiteDaoSql = new WebSiteDAOSQL();
		webSiteDaoSql.getWebSite(taskid);
		SiteUrl siteurl = webSiteDaoSql.getWebSite(siteid);
		
		TaskDAOSQL taskdaosql = new TaskDAOSQL();
		
		List<TaskUrl> list = taskdaosql.getTaskUrlsByTaskId(taskid);
		Iterator<TaskUrl> taskUrlList = list.iterator();
		while(taskUrlList.hasNext()){
			TaskDataQueue.taskUrlQueue.put(taskUrlList.next());
		}
		IHandler<TaskUrl, TaskContentUrl> handler = new TaskUrlHandler();
		CollectTask col = new CollectTaskImpl();
		col.discoveryTaskContentUrl(handler);
		col.discoveryPageContent(new ContentUrlHandler());
	}
}
